﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Remember
{
    public class MainWindowViewModel : ObjectBase
    {
        private List<Note> upcomingNotes;
        private List<Note> passedNotes;
        private Note selectedUpcomingNote;
        private Note selectedPassedNote;

        public NotesManager NotesManager;

        public MainWindowViewModel(Views.MainWindow mainWindow)
        {
            NotesManager = new NotesManager();
            UpcomingNotes = NotesManager.GetUpcomingNotes();
            TrayManager = new TrayManager(this, mainWindow);
            PassedNotes = NotesManager.GetPassedMotes();
            Commands = new Commands(this);
        }

        public Commands Commands { get; private set; }

        public List<Note> UpcomingNotes
        {
            get { return this.upcomingNotes; }
            set
            {
                if (this.upcomingNotes == value)
                    return;
                this.upcomingNotes = value;
                OnPropertyChanged("UpcomingNotes");
            }
        }

        public List<Note> PassedNotes
        {
            get { return this.passedNotes; }
            set
            {
                if (this.passedNotes == value)
                    return;
                this.passedNotes = value;
                OnPropertyChanged("PassedNotes");
            }
        }

        public Note SelectedUpcomingNote 
        {
            get { return this.selectedUpcomingNote; } 
            set
            {
                if (this.selectedUpcomingNote == value)
                    return;
                this.selectedUpcomingNote = value;
                OnPropertyChanged("SelectedUpcomingNote");
            }
        }

        public Note SelectedPassedNote
        {
            get { return this.selectedPassedNote; }
            set
            {
                if (this.selectedPassedNote == value)
                    return;
                this.selectedPassedNote = value;
                OnPropertyChanged("SelectedPassedNote");
            }
        }

        public void Refresh()
        {
            UpcomingNotes = NotesManager.GetUpcomingNotes();
            PassedNotes = NotesManager.GetPassedMotes();
        }

        public TrayManager TrayManager
        {
            get;
            private set;
        }
    }
}
